package com.dhnsoft.shortLink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dhnsoft.shortLink.project.dao.entity.LinkBrowserStatsDO;
import com.dhnsoft.shortLink.project.dto.req.ShortLinkStatsReqDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.HashMap;
import java.util.List;

/**
 * ClassName: linkBrowserStatsMapper
 * Package: com.dhnsoft.shortLink.project.dao.mapper
 * Description: 操作系统统计访问持久层
 *
 * @Author dhn
 * @Create 2024/4/7 10:06
 * @Version 1.0
 */
public interface LinkBrowserStatsMapper extends BaseMapper<LinkBrowserStatsDO> {


    @Insert("insert into t_link_browser_stats(full_short_url,gid,date,cnt,browser,create_time,update_time,del_flag)" +
            "values(#{linkBrowserStats.fullShortUrl},#{linkBrowserStats.gid},#{linkBrowserStats.date},#{linkBrowserStats.cnt}" +
            ",#{linkBrowserStats.browser},now(),now(),0)ON DUPLICATE KEY UPDATE cnt=cnt+#{linkBrowserStats.cnt}," +
            "update_time=now()")
    void linkBrowserStats(@Param("linkBrowserStats") LinkBrowserStatsDO linkBrowserStatsMapperDO);

    List<HashMap<String, Object>> listBrowserStatsByShortLink(@Param("param") ShortLinkStatsReqDTO requestParam);
}
